<%@ page language="java" import="java.util.*" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%@include file="/context/mytags.jsp"%>
<!DOCTYPE html>
<html>
	<head>
		<title>工序汇报</title>
		<t:base type="jquery,easyui,tools,DatePicker,utils,yongxin"></t:base>
	</head>

<script>
 	$(function(){
 			$.ajax({
				type : "POST",
				url : "processReport10Controller.do?getProcess&fbcph=${processReportPage.fbcph}",
				data: {},
				success : function(jsondata) {
						data = $.parseJSON(jsondata);
						var str ="";
						$(data.obj).each(function(i,j){
							//console.log(j);
							str +="<span class='progress'>"+j.typename+"("+j.fbcph+")</span>";
							if(i%6==0){
								str +="<br><br>";
							}
							str +="<span >-----></span>";
							//console.log(str);
						});
						//str +=data.msg;
						
						console.log(str);
						$('#div_process').html(str);
						$('#div_nprocess').html(data.msg);
						$('#t_div_nprocess').html(data.msg);
						$('#nprocess').val('${processReportPage.nprocess}');
					}
			});
			
			var char=['A','B','C','D','E','F','G','H','I','J','K','L','M','N','O','P','Q','R','S','T','U','V','W','X','Y','Z'];
			var num = 0;
			var lastCommunAddTr = $(".trRecords:last");

		   $("#add_btn").click(function() {//复制一行
		   
               var tr = $("#temp_tr_records").clone();
               tr.attr('id',tr.attr('id')+char[num]);
          		
          	   tr.attr('class','trRecords');
          	   
               tr.insertAfter(lastCommunAddTr);
               lastCommunAddTr = tr;
               num++;
              
            });
            
            $("#del_btn").click(function() {//复制一行
              var delIndexs = new Array(0);
              
            $(".trRecords:gt(0)").each(function(i) {
              		
					if($(this).find("#ck").get(0).checked == true){
                  		delIndexs.splice(delIndexs.length,0,i);
                     	$(this).remove();
                     	
                    }
					 
                });
            /*       $(".trRecords:gt( ${fn:length(productList)-1})").each(function(i) {
              		
					if($(this).find("#ck").get(0).checked == true){
                  		delIndexs.splice(delIndexs.length,0,i);
                     	$(this).remove();
                    }
                });*/
                
                
                 $(".trRecords").each(function(i) {
                 	lastCommunAddTr = $(this);
                 
                });
            });
            $("#save_btn").click(function() {//复制一行
               top.$(".ui_state_highlight").hide();
              	ajaxdoForm('processReport10Controller.do?save&fstate=1','formobj');
            });
            
            
            $('#ftrzls').blur(function() {
            
               var a = $('#ftrzl').val();
               var b = $('#ftrzls').val();
               if(b > a){
                 tip("分切投入重量不能大于投入重量");
                 $('#ftrzls').focus();
                 return false;
               }
               $('#fbfzl').val((a - b).toFixed(2));
            });
           selChange(); 
           
           
           
          
           $("input[name='fnprocess']").each(function(i) {
           		$(this).click(function() {
            		opensubwin("子窗口","","");	
	                 return;
                 });
            });
           
           
           
           
           
 	});
    
     function selChange(){

  var sel = $("#fworkshop").val();
  $.ajax({
		type : "POST",
		url : "processReportController.do?getMatchinegroupList&process=${processReportPage.cprocess}",
		data: {pid:$('#fworkshop').val()},
		success : function(jsondata) {
				data = $.parseJSON(jsondata);
				console.log(data);
				$('#fmatchinegroup').html(data.msg);
			  	$('#fmatchinegroup').val("${processReportPage.fmatchinegroup}");
			}
	});
	
}
 </script>

	<body  scroll="no">
		<div id="wrapper">
			<div id="scroller">
				<div>
					<t:formvalid formid="formobj" dialog="true" usePlugin="password" layout="table" tiptype="1"
						action="processReport10Controller.do?save&fstate=2" beforeSubmit="checkNprocessLeftEmpty">
						<input id="id" name="id" type="hidden" value="${processReportPage.id }">
						<input type="hidden" id="cprocess" name="cprocess" class="mytxt" ignore="ignore" value="${processReportPage.cprocess}">
						<table  cellpadding="0" cellspacing="1" class="formtable">
							<tr>
								<td align="center" colspan=11>
									<label class="Validform_label">
										纵剪工序汇报单
									</label>
								</td>
							</tr>
							<tr>
								<td align="center" colspan=11 style="background-color: white; padding: 20px">
									<div id="div_process"></div>
								</td>
							</tr>
							<tr style="display: none">
								<td align="center">
									<label class="Validform_label">
										制单时间
									</label>
								</td>
								<td class="value" colspan=10>
									<input class="mytxt" style="width: 140px" id="updateDate" name="updateDate" class="mytxt" ignore="ignore"
										value="<fmt:formatDate value='${processReportPage.updateDate}' type="date" pattern="yyyy-MM-dd HH:mm:ss"/>" ReadOnly>
									<!-- 	<input class="Wdate" onClick="WdatePicker({dateFmt:'yyyy-MM-dd HH:mm:ss'})" style="width: 150px" id="createDate"
							name="createDate" class="mytxt"  ignore="ignore">   -->
								</td>
							</tr>
							<tr>
								<td align="center">
									<label class="Validform_label">
										生产车间
									</label>
								</td>
								<td class="value" colspan=10>
									<!--<t:dictSelect field="fworkshop" typeGroupCode="workshop" hasLabel="false"  defaultVal="${processReportPage.fworkshop}" extendJson="{id:sel2}"></t:dictSelect>
								-->
								    <select  id="fworkshop"  name="fworkshop" onchange="selChange()">
								     <c:forEach items="${workshopList}" var="workshop">
								        <option value="${workshop.id}"   <c:if test="${workshop.id==processReportPage.fworkshop}"> selected="selected"</c:if>>${workshop.name}</option>
								     </c:forEach>
								     </select>
								</td>
							</tr>
							<tr>
								<td align="center">
									<label class="Validform_label">
										班组
									</label>
								</td>
								<td class="value" colspan=10>
									 <t:dictSelect field="fworkgroup" typeGroupCode="team" hasLabel="false"  defaultVal="${processReportPage.fworkgroup}" extendJson="{id:sel2}"></t:dictSelect>
								</td>
							</tr>
							<tr>
								<td align="center">
									<label class="Validform_label">
										机组
									</label>
								</td>
								<td class="value" colspan=10>
									<!--<input id="fmatchinegroup" name="fmatchinegroup" style="width: 140px;" class="mytxt" ignore="ignore"
										value="${processReportPage.fmatchinegroup}">
								-->
								 <select id='fmatchinegroup' name='fmatchinegroup'><option value=''>请选择</option></select>
								</td>
							</tr>
							<tr style="display: none">
								<td align="center">
									<label class="Validform_label">
										制单人
									</label>
								</td>
								<td class="value" colspan=10>
									<input id="createBy" name="createBy" style="width: 140px;" class="mytxt" ignore="ignore" readOnly
										value="${processReportPage.createBy}">

								</td>
							</tr>
							<tr>
								<td align="center">
									<label class="Validform_label">
										本厂批号
									</label>
								</td>
								<td align="center">
									<label class="Validform_label">
										投入厚度
									</label>
								</td>
								<td align="center">
									<label class="Validform_label">
										投入宽度
									</label>
								</td>
								<td align="center">
									<label class="Validform_label">
										投入重量
									</label>
								</td>
								<td align="center">
									<label class="Validform_label">
										产出厚度
									</label>
								</td>
								<td align="center">
									<label class="Validform_label">
										产出宽度
									</label>
								</td>
								<td align="center">
									<label class="Validform_label">
										剩余重量
									</label>
								</td>

								<td align="center">
									<label class="Validform_label">
										质量情况
									</label>
								</td>
								<td align="center">
									<label class="Validform_label">
										下一工序
									</label>
								</td>
							</tr>

							<tr id="record_tr" class="trRecord">
								<td align="center" class="value">
									<input id="fbcph" name="fbcph" class="mytxt" ignore="ignore" value="${processReportPage.fbcph}" style="width: 120px"
										ReadOnly>
								</td>
								<td align="center" class="value">

									<input id="ftrhd" name="ftrhd" class="mytxt" ignore="ignore" value="${processReportPage.ftrhd}" ReadOnly>
								</td>
								<td align="center" class="value">
									<input id="ftrkd" name="ftrkd" class="mytxt" ignore="ignore" value="${processReportPage.ftrkd}" ReadOnly>
								</td>
								<td align="center" class="value">
									<input id="ftrzl" name="ftrzl" class="mytxt" ignore="ignore" value="${processReportPage.ftrzl}" ReadOnly>
								</td>
								<td align="center" class="value">

									<input id="fcchd" name="fcchd" class="mytxt" ignore="ignore" dataType="d" value="${processReportPage.fcchd}">
								</td>
								<td align="center" class="value">
									<input id="fcckd" name="fcckd" class="mytxt" ignore="ignore" dataType="d" value="${processReportPage.fcckd}">
								</td>
								<td align="center" class="value">
									<input id="fbfzl" name="fbfzl" class="mytxt" ignore="ignore" value="${processReportPage.fbfzl}" ReadOnly>
								</td>
								<td align="center" class="value">
									<input id="fnote" name="fnote" class="mytxt" ignore="ignore" value="${processReportPage.fnote}">
								</td>
								<td align="center" class="value">
									<div id="div_nprocess" class="div_nprocess"></div>
								</td>
							</tr>
							<tr>
								<td align="center">
									<label class="Validform_label">
										本厂批号
									</label>
								</td>
								<td align="center">
									<label class="Validform_label">
										投入厚度
									</label>
								</td>
								<td align="center">
									<label class="Validform_label">
										投入宽度
									</label>
								</td>

								<td align="center">
									<label class="Validform_label">
										投入重量
									</label>
								</td>
								<td align="center">
									<label class="Validform_label">
										分切厚度
									</label>
								</td>
								<td align="center">
									<label class="Validform_label">
										分切宽度
									</label>
								</td>

								<td align="center">
									<label class="Validform_label">
										分切重量
									</label>
								</td>
								<td align="center">
									<label class="Validform_label">
										卷数
									</label>
								</td>

								<td align="center">
									<label class="Validform_label">
										备注
									</label>
								</td>

							</tr>


							<c:if test="${fn:length(productList)  > 0 }">
								<c:forEach items="${productList}" var="poVal" varStatus="stuts">
									<tr id="records_tr" class="trRecords">
										<c:if test="${stuts.index==0}">
											<td align="center" class="value" rowspan=100>
												<input id="fbcph" name="fbcphs" class="mytxt" ignore="ignore" value="${processReportPage.fbcph}"
													style="width: 120px" ReadOnly>
											</td>

											<td align="center" class="value" rowspan=100>

												<input id="ftrhds" name="ftrhds" class="mytxt" ignore="ignore" dataType="d" value="${poVal.ftrhd}">
												<input id="ids" name="ids" class="mytxt" ignore="ignore" type="hidden" value="${poVal.id}">
											</td>
											<td align="center" class="value" rowspan=100>
												<input id="ftrkds" name="ftrkds" class="mytxt" ignore="ignore" dataType="d" value="${poVal.ftrkd}">
											</td>
											<td align="center" class="value" rowspan=100>
												<input id="ftrzls" name="ftrzls" class="mytxt" ignore="ignore" dataType="d" value="${poVal.ftrzl}">
											</td>
										</c:if>
										<c:if test="${stuts.index ==0}">
											<td align="center" class="value">
												<input id="ffqhd" name="ffqhd" class="mytxt" ignore="ignore" dataType="d" value="${poVal.ffqhd}">
											</td>
										</c:if>
										<c:if test="${stuts.index>0}">
											<td align="left" class="value">
												<input type="checkbox" id="ck">
												<input id="ffqhd" name="ffqhd" class="mytxt" ignore="ignore" dataType="d" value="${poVal.ffqhd}">
											</td>
										</c:if>
										<td align="center" class="value">
											<input id="ffqkd" name="ffqkd" class="mytxt" ignore="ignore" dataType="d" value="${poVal.ffqkd}">
										</td>
										<td align="center" class="value">
											<input id="ffqzl" name="ffqzl" class="mytxt" ignore="ignore" dataType="d" value="${poVal.ffqzl}">
										</td>
										<td align="center" class="value">
											<input id="ffqjs" name="ffqjs" class="mytxt" ignore="ignore" dataType="n" value="${poVal.ffqjs}">
										</td>
										<td align="center" class="value">
											<input type="button" id="fnprocess" name="fnprocess"  value="下一工序">
										</td>
										<td align="center" class="value">
											<input id="fnote" name="note" class="mytxt" ignore="ignore" value="${poVal.fnote}">
										</td>
									</tr>
								</c:forEach>
							</c:if>


							<c:if test="${fn:length(productList) <= 0 }">
								<tr id="records_tr" class="trRecords">
									<td align="center" class="value" rowspan=100>
										<input id="fbcph" name="fbcphs" class="mytxt" ignore="ignore" value="${processReportPage.fbcph}"
											style="width: 120px" ReadOnly>
									</td>
									<td align="center" class="value" rowspan=100>

										<input id="ftrhds" name="ftrhds" class="mytxt" ignore="ignore" dataType="d" value="${poVal.ftrhd}">
										<input id="ids" name="ids" class="mytxt" ignore="ignore" type="hidden" value="${poVal.id}">
									</td>
									<td align="center" class="value" rowspan=100>
										<input id="ftrkds" name="ftrkds" class="mytxt" ignore="ignore" dataType="d" value="${poVal.ftrkd}">
									</td>
									<td align="center" class="value" rowspan=100>
										<input id="ftrzls" name="ftrzls" class="mytxt" ignore="ignore" dataType="d" value="${poVal.ftrzl}">
									</td>
									<td align="center" class="value">

										<input id="ffqhd" name="ffqhd" class="mytxt" ignore="ignore" dataType="d" value="${poVal.ffqhd}">
									</td>
									<td align="center" class="value">
										<input id="ffqkd" name="ffqkd" class="mytxt" ignore="ignore" dataType="d" value="${poVal.ffqkd}">
									</td>
									<td align="center" class="value">
										<input id="ffqzl" name="ffqzl" class="mytxt" ignore="ignore" dataType="d" value="${poVal.ffqzl}">
									</td>
									<td align="center" class="value">
										<input id="ffqjs" name="ffqjs" class="mytxt" ignore="ignore" dataType="d" value="${poVal.ffqjs}">
									</td>
									<td align="center" class="value">
										<input type="button" id="fnprocess" name="fnprocess" value="下一工序">
									</td>
									<td align="center" class="value">
										<input id="fnote" name="note" class="mytxt" ignore="ignore" value="${poVal.fnote}">
									</td>
								</tr>
							</c:if>
						</table>
					</t:formvalid>
					<div id="dlg-buttons" >
						<table cellpadding="0" cellspacing="0" style="width: 100%">
							<tr>
								<td style="padding-top: 10px">
									<a href="#" class="easyui-linkbutton btn" iconCls="icon-save" id="save_btn">保存</a>
									<a href="#" class="easyui-linkbutton btn" iconCls="icon-add" id="add_btn">增加分切</a>
									<a href="#" class="easyui-linkbutton btn" iconCls="icon-del" id="del_btn">删除分切</a>
								</td>
							</tr>
						</table>
					</div>



					<table style="width: 600px; display: none" cellpadding="0" cellspacing="1">

						<tr id="temp_tr_records">
							<td align="left" class="value">
								<input type="checkbox" id="ck">
								<input id="ffqhd" name="ffqhd" class="mytxt" ignore="ignore" dataType="d">
							</td>
							<td align="center" class="value">
								<input id="ffqkd" name="ffqkd" class="mytxt" ignore="ignore" dataType="d">
							</td>
							<td align="center" class="value">
								<input id="ffqzl" name="ffqzl" class="mytxt" ignore="ignore" dataType="d">
							</td>
							<td align="center" class="value">
								<input id="ffqjs" name="ffqjs" class="mytxt" ignore="ignore" dataType="n">
							</td>
							<td align="center" class="value">
								<input type="button" id="fnprocess" name="fnprocess" value="下一工序">
							</td>
							<td align="center" class="value">
								<input id="fnote" name="note" class="mytxt" ignore="ignore">
							</td>
						</tr>
					</table>
				</div>
			</div>
		</div>
	</body>